var jAjax = {
	init: function(){
				var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
				 if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
				  for (var i=0; i<activexmodes.length; i++){
				   try{
					return new ActiveXObject(activexmodes[i])
				   }
				   catch(e){
					//suppress error
				   }
				  }
				 }
				 else if (window.XMLHttpRequest) // if Mozilla, Safari etc
				  return new XMLHttpRequest()
				 else
				  return false
			},
	ajax: function(opts){
				if(!opts) return this;
				target = this;
				aUrl = opts.url || null;
				aParam = opts.param || null;
				aMethod = opts.method || "GET";
				aMethod = aMethod.toUpperCase();
				aComplete = opts.post || null;
				aPre = opts.pre || null;
				aDecode = opts.decode || null;
				aOperation = opts.operation || "return";
				aLoadingText = opts.loadingText || "Loading...";
				aLoadingObject = opts.loadingObject || null;
				oLoading = aLoadingObject !== null ? j$('#'+aLoadingObject) : null;


				ajaxObj = jAjax.init();
				ajaxObj.open(aMethod, aUrl, true);
				if(aMethod == "POST") ajaxObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");   
				ajaxObj.onreadystatechange = function(){
												if(ajaxObj.readyState == 4){
													if(ajaxObj.status == 200){

														if(oLoading !== null) oLoading.text("");

														t = ajaxObj.responseText;
														if(aComplete !== null){
															aComplete(t);
														}
														/*if(aDecode == "json"){
															
														} else
														if(aDecode == "xml"){
															
														}*/

														if(aOperation === "return") {
															return t;
														} else
														if(aOperation === "eval") {
															eval(t);
														} else
														if(aOperation === "update"){
															target.text(t);
														}
													}	
												}
											};
				if(aPre !== null) aPre.call(this);
				if(oLoading !== null) oLoading.text(aLoadingText);
				ajaxObj.send(aParam);
			 }
}
jarvis.extend(jAjax);
